﻿//-----------------------------------------------------------------------
// <copyright file="EdgesStatusBar.cs" company="Luboš Bretschnieder">
// Copyright (c) 2008 Luboš Bretschnieder, Licensed under the Apache License, Version 2.0.
// </copyright>
//-----------------------------------------------------------------------
namespace Graphs.UI.StatusBars
{
    using System.Collections.Generic;
    using System.Text;

    /// <summary>
    /// Processed edges status bar
    /// </summary>
    public class EdgesStatusBar : IStatusBar
    {
        /// <summary>
        /// Gets or sets the label.
        /// </summary>
        /// <value>The label.</value>
        public string Label { get; set; }

        /// <summary>
        /// Gets or sets the edges.
        /// </summary>
        /// <value>The edges.</value>
        public IEnumerable<Edge> Edges { private get; set; }

        /// <summary>
        /// Converts the status information to simple string.
        /// </summary>
        /// <returns>
        /// String representation of status information.
        /// </returns>
        public string ToStatusString()
        {
            if (this.Edges == null)
            {
                return string.Empty;
            }

            StringBuilder sb = new StringBuilder();

            foreach (Edge edge in this.Edges)
            {
                if (sb.Length > 0)
                {
                    sb.Append(", ");
                }

                sb.Append(edge.From.Name);
                sb.Append(edge.To.Name);
            }

            return sb.ToString();
        }
    }
}
